
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>RabbitMQ中的不同交换机类型有什么区别 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>RabbitMQ中的不同交换机类型有什么区别 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">RabbitMQ 提供了哪四种主要的交换机（Exchange）类型？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">RabbitMQ 提供了四种主要的交换机类型，分别是：Direct (直连交换机)、Fanout (广播交换机)、Topic (主题交换机) 和 Headers (头部交换机)。</div>
          </div>
          <div class="card-source">来源: 文档开篇部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Direct Exchange (直连交换机) 的消息路由策略是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Direct Exchange 根据精确的路由键（Routing Key）来路由消息。生产者发送消息时指定一个路由键，交换机会将消息精确地分发给绑定了相同路由键的队列。</div>
          </div>
          <div class="card-source">来源: 1. Direct Exchange（直连交换机）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Fanout Exchange (广播交换机) 是如何处理路由键的？它会将消息发送到哪里？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Fanout Exchange 不处理路由键，会忽略消息的路由键。它会将接收到的消息广播给所有与该交换机绑定的队列。</div>
          </div>
          <div class="card-source">来源: 2. Fanout Exchange（广播交换机）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Topic Exchange (主题交换机) 中用于模式匹配的两种通配符是什么，它们分别代表什么含义？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Topic Exchange 使用的两种通配符是：`*` (星号) 和 `#` (井号)。`*` 匹配一个单词，而 `#` 匹配零个或多个单词。</div>
          </div>
          <div class="card-source">来源: 3. Topic Exchange（主题交换机）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Headers Exchange (头部交换机) 的路由依据是什么，与其它交换机有何根本不同？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Headers Exchange 的路由依据是消息头（Headers）中的属性，而不是路由键。这是它与其他交换机的根本不同之处。</div>
          </div>
          <div class="card-source">来源: 4. Headers Exchange（头部交换机）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">在 Headers Exchange 中，`x-match` 参数的 `all` 和 `any` 两个值有什么区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在 Headers Exchange 中，`x-match` 参数的 `all` 值要求消息的所有指定头部键值对都必须匹配，而 `any` 值则表示只要有一个头部键值对匹配即可。</div>
          </div>
          <div class="card-source">来源: 4. Headers Exchange（头部交换机）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">哪种交换机最适合用于广播消息的场景，例如需要将一条消息发送给所有消费者的实时更新系统？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Fanout Exchange (广播交换机) 最适合用于广播消息的场景，因为它会将消息分发给所有绑定的队列，无需关心路由键。</div>
          </div>
          <div class="card-source">来源: 2. Fanout Exchange（广播交换机）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">当需要根据消息的多个属性（如 `region` 和 `language`）进行复杂路由时，应优先考虑使用哪种交换机？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">应优先考虑使用 Headers Exchange (头部交换机)，因为它基于消息头中的多个属性进行路由，适用于路由键灵活性不够的复杂场景。</div>
          </div>
          <div class="card-source">来源: 4. Headers Exchange（头部交换机）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">在日志系统中，如果需要根据消息级别和来源模块（如 `auth.error`）进行灵活的、基于模式的路由，应该使用哪种交换机？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">应该使用 Topic Exchange (主题交换机)，因为它允许使用带有通配符的路由键，可以灵活地定义复杂的路由规则来匹配不同的日志来源和级别。</div>
          </div>
          <div class="card-source">来源: 3. Topic Exchange（主题交换机）</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
